package fan.com.httpframe;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import java.util.ArrayList;

import fan.com.httpframe.activity.BaseActivity;
import fan.com.httpframe.http.ApiManager;
import fan.com.httpframe.http.BaseSubscriber;
import fan.com.httpframe.http.RxSchedulers;
import fan.com.httpframe.http.bean.NewImageBeanListBean;
import fan.com.httpframe.http.bean.UserInfoBean;
import fan.com.httpframe.http.requst.RequestBodyUtils;

public class MainActivity extends BaseActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button bt = findView(R.id.bt);
        Button bt1 = findView(R.id.bt1);

        final ArrayList list = new ArrayList();
        list.add("0");
        list.add("liangfan");
        list.add("liangfan123456");

        bt1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ApiManager.getApi().getHomeNewsImg(RequestBodyUtils.getHomeNewsImg())
                        .compose(loadingDialog())
                        .compose(RxSchedulers.io_main())
                        .subscribe(new BaseSubscriber<NewImageBeanListBean>() {
                            @Override
                            public void result(NewImageBeanListBean newImageBeanListBean) {
                                System.out.println("liangfan  "+newImageBeanListBean.getDATA().get(0).getIMG());
                            }
                        });
            }
        });


        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ApiManager.getApi().login(RequestBodyUtils.login(list))
                        .compose(loadingDialog())
                        .compose(RxSchedulers.io_main())
                        .subscribe(new BaseSubscriber<UserInfoBean>() {
                            @Override
                            public void result(UserInfoBean userInfoBean) {
                                System.out.println("liangfan  "+userInfoBean.getDATA().getAUTHTOKEN());
                            }
                        });

            }
        });

    }

}
